.class Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;
.super Ljava/lang/Thread;
.source "ZMDownloadManager.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;->handleEnqueue(Landroid/content/Context;Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadFileExistCallback;Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadingCallback;)J
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field final synthetic this$0:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;

.field final synthetic val$downloadingCallback:Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadingCallback;

.field final synthetic val$fileExistCallback:Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadFileExistCallback;

.field final synthetic val$mContext:Landroid/content/Context;

.field final synthetic val$mHandler:Landroid/os/Handler;

.field final synthetic val$query:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Query;

.field final synthetic val$request:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;


# direct methods
.method constructor <init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Query;Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadFileExistCallback;Landroid/os/Handler;Landroid/content/Context;Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadingCallback;)V
    .registers 8
    .param p1, "this$0"    # Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;

    .prologue
    .line 858
    iput-object p1, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->this$0:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;

    iput-object p2, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$query:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Query;

    iput-object p3, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$request:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;

    iput-object p4, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$fileExistCallback:Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadFileExistCallback;

    iput-object p5, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    iput-object p6, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mContext:Landroid/content/Context;

    iput-object p7, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$downloadingCallback:Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadingCallback;

    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .registers 13

    .prologue
    .line 861
    const/4 v1, 0x0

    .line 863
    .local v1, "c":Landroid/database/Cursor;
    :try_start_1
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->this$0:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;

    iget-object v9, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$query:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Query;

    invoke-virtual {v8, v9}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;->query(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Query;)Landroid/database/Cursor;

    move-result-object v1

    .line 865
    :cond_9
    :goto_9
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_c
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_c} :catch_be
    .catchall {:try_start_1 .. :try_end_c} :catchall_e1

    move-result v8

    if-eqz v8, :cond_136

    .line 867
    :try_start_f
    const-string v8, "_id"

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v8

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getInt(I)I

    move-result v8

    int-to-long v2, v8

    .line 868
    .local v2, "downId":J
    const-string v8, "download_url"

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v8

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v4

    .line 869
    .local v4, "reqUrl":Ljava/lang/String;
    const-string v8, "status"

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v8

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getInt(I)I

    move-result v5

    .line 870
    .local v5, "status":I
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$request:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;

    # getter for: Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;->mUri:Landroid/net/Uri;
    invoke-static {v8}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;->access$000(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;)Landroid/net/Uri;

    move-result-object v8

    invoke-virtual {v8}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v8, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v8

    if-eqz v8, :cond_9

    .line 871
    const-string v7, ""
    :try_end_40
    .catch Ljava/lang/Throwable; {:try_start_f .. :try_end_40} :catch_9f
    .catchall {:try_start_f .. :try_end_40} :catchall_e1

    .line 873
    .local v7, "tFilePath":Ljava/lang/String;
    :try_start_40
    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v8, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "local_uri"

    invoke-interface {v1, v9}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v9

    invoke-interface {v1, v9}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v9

    const-string v10, "file://"

    const-string v11, ""

    invoke-virtual {v9, v10, v11}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
    :try_end_62
    .catch Ljava/lang/Throwable; {:try_start_40 .. :try_end_62} :catch_13c
    .catchall {:try_start_40 .. :try_end_62} :catchall_e1

    move-result-object v7

    .line 877
    :goto_63
    move-object v0, v7

    .line 878
    .local v0, "apkPath":Ljava/lang/String;
    const/16 v8, 0x8

    if-ne v5, v8, :cond_e8

    :try_start_68
    invoke-static {v0}, Lcom/zuimeia/sdk/download/utils/AppIOUtil;->isFileExist(Ljava/lang/String;)Z

    move-result v8

    if-eqz v8, :cond_e8

    .line 879
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$fileExistCallback:Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadFileExistCallback;

    if-eqz v8, :cond_d6

    .line 880
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$1;

    invoke-direct {v9, p0}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$1;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 887
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$fileExistCallback:Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadFileExistCallback;

    invoke-virtual {v8}, Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadFileExistCallback;->isNeedDownloadedCallback()Z

    move-result v8

    if-eqz v8, :cond_94

    .line 888
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$2;

    invoke-direct {v9, p0}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$2;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
    :try_end_8e
    .catch Ljava/lang/Throwable; {:try_start_68 .. :try_end_8e} :catch_9f
    .catchall {:try_start_68 .. :try_end_8e} :catchall_e1

    .line 974
    :goto_8e
    if-eqz v1, :cond_93

    .line 975
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    .line 986
    .end local v0    # "apkPath":Ljava/lang/String;
    .end local v2    # "downId":J
    .end local v4    # "reqUrl":Ljava/lang/String;
    .end local v5    # "status":I
    .end local v7    # "tFilePath":Ljava/lang/String;
    :cond_93
    :goto_93
    return-void

    .line 896
    .restart local v0    # "apkPath":Ljava/lang/String;
    .restart local v2    # "downId":J
    .restart local v4    # "reqUrl":Ljava/lang/String;
    .restart local v5    # "status":I
    .restart local v7    # "tFilePath":Ljava/lang/String;
    :cond_94
    :try_start_94
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$3;

    invoke-direct {v9, p0, v0}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$3;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;Ljava/lang/String;)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
    :try_end_9e
    .catch Ljava/lang/Throwable; {:try_start_94 .. :try_end_9e} :catch_9f
    .catchall {:try_start_94 .. :try_end_9e} :catchall_e1

    goto :goto_8e

    .line 966
    .end local v0    # "apkPath":Ljava/lang/String;
    .end local v2    # "downId":J
    .end local v4    # "reqUrl":Ljava/lang/String;
    .end local v5    # "status":I
    .end local v7    # "tFilePath":Ljava/lang/String;
    :catch_9f
    move-exception v6

    .line 967
    .local v6, "t":Ljava/lang/Throwable;
    :try_start_a0
    const-string v8, ""

    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    const-string v10, "downId error="

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v6}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v8, v9}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_bc
    .catch Ljava/lang/Throwable; {:try_start_a0 .. :try_end_bc} :catch_be
    .catchall {:try_start_a0 .. :try_end_bc} :catchall_e1

    goto/16 :goto_9

    .line 971
    .end local v6    # "t":Ljava/lang/Throwable;
    :catch_be
    move-exception v8

    .line 974
    if-eqz v1, :cond_c4

    .line 975
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    .line 978
    :cond_c4
    :goto_c4
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$9;

    invoke-direct {v9, p0}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$9;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 985
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->this$0:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;

    iget-object v9, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$request:Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;

    invoke-virtual {v8, v9}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager;->enqueue(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$Request;)J

    goto :goto_93

    .line 911
    .restart local v0    # "apkPath":Ljava/lang/String;
    .restart local v2    # "downId":J
    .restart local v4    # "reqUrl":Ljava/lang/String;
    .restart local v5    # "status":I
    .restart local v7    # "tFilePath":Ljava/lang/String;
    :cond_d6
    :try_start_d6
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$4;

    invoke-direct {v9, p0, v0}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$4;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;Ljava/lang/String;)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
    :try_end_e0
    .catch Ljava/lang/Throwable; {:try_start_d6 .. :try_end_e0} :catch_9f
    .catchall {:try_start_d6 .. :try_end_e0} :catchall_e1

    goto :goto_8e

    .line 974
    .end local v0    # "apkPath":Ljava/lang/String;
    .end local v2    # "downId":J
    .end local v4    # "reqUrl":Ljava/lang/String;
    .end local v5    # "status":I
    .end local v7    # "tFilePath":Ljava/lang/String;
    :catchall_e1
    move-exception v8

    if-eqz v1, :cond_e7

    .line 975
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    :cond_e7
    throw v8

    .line 924
    .restart local v0    # "apkPath":Ljava/lang/String;
    .restart local v2    # "downId":J
    .restart local v4    # "reqUrl":Ljava/lang/String;
    .restart local v5    # "status":I
    .restart local v7    # "tFilePath":Ljava/lang/String;
    :cond_e8
    const/4 v8, 0x1

    if-eq v5, v8, :cond_ee

    const/4 v8, 0x2

    if-ne v5, v8, :cond_10d

    .line 925
    :cond_ee
    :try_start_ee
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$downloadingCallback:Lcom/zuimeia/sdk/download/providers/downloads/callback/ZMDownloadingCallback;

    if-eqz v8, :cond_102

    .line 926
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$5;

    invoke-direct {v9, p0}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$5;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
    :try_end_fc
    .catch Ljava/lang/Throwable; {:try_start_ee .. :try_end_fc} :catch_9f
    .catchall {:try_start_ee .. :try_end_fc} :catchall_e1

    .line 974
    :goto_fc
    if-eqz v1, :cond_93

    .line 975
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto :goto_93

    .line 935
    :cond_102
    :try_start_102
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$6;

    invoke-direct {v9, p0}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$6;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    goto :goto_fc

    .line 944
    :cond_10d
    const/4 v8, 0x4

    if-ne v5, v8, :cond_121

    .line 945
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$7;

    invoke-direct {v9, p0, v2, v3}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$7;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;J)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
    :try_end_11a
    .catch Ljava/lang/Throwable; {:try_start_102 .. :try_end_11a} :catch_9f
    .catchall {:try_start_102 .. :try_end_11a} :catchall_e1

    .line 974
    if-eqz v1, :cond_93

    .line 975
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto/16 :goto_93

    .line 954
    :cond_121
    const/16 v8, 0x10

    if-ne v5, v8, :cond_9

    .line 955
    :try_start_125
    iget-object v8, p0, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;->val$mHandler:Landroid/os/Handler;

    new-instance v9, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$8;

    invoke-direct {v9, p0, v2, v3}, Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1$8;-><init>(Lcom/zuimeia/sdk/download/providers/ZMDownloadManager$1;J)V

    invoke-virtual {v8, v9}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
    :try_end_12f
    .catch Ljava/lang/Throwable; {:try_start_125 .. :try_end_12f} :catch_9f
    .catchall {:try_start_125 .. :try_end_12f} :catchall_e1

    .line 974
    if-eqz v1, :cond_93

    .line 975
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto/16 :goto_93

    .line 974
    .end local v0    # "apkPath":Ljava/lang/String;
    .end local v2    # "downId":J
    .end local v4    # "reqUrl":Ljava/lang/String;
    .end local v5    # "status":I
    .end local v7    # "tFilePath":Ljava/lang/String;
    :cond_136
    if-eqz v1, :cond_c4

    .line 975
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto :goto_c4

    .line 874
    .restart local v2    # "downId":J
    .restart local v4    # "reqUrl":Ljava/lang/String;
    .restart local v5    # "status":I
    .restart local v7    # "tFilePath":Ljava/lang/String;
    :catch_13c
    move-exception v8

    goto/16 :goto_63
.end method
